package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itheima.domain.db.Freeze;
import com.itheima.mapper.FreezeMapper;
import com.itheima.service.db.FreezeService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

@Service
public class FreezeServiceImpl implements FreezeService {


    @Autowired
    private FreezeMapper freezeMapper;

    /*
     *
     *  添加冻结用户
     * @param freeze
     * @author
     * @date
     * @return void
     */

    @Override
    public int saveUserFreeze(Freeze freeze) {
        return freezeMapper.insert(freeze);

    }

    /*
     *
     *
     * @param userId 登录用户Id
     * @author
     * @date
     * @return com.itheima.domain.db.Freeze
     */

    @Override
    public Freeze findByUser(Long userId) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",userId);
        return freezeMapper.selectOne(queryWrapper);

    }

    /*
     *  删除冻结数据
     *
     * @param userId    用户Id
     * @author
     * @date
     * @return void
     */

    @Override
    public void deleteUserFreeze(Integer userId) {
        QueryWrapper queryWrapper=new QueryWrapper();
        queryWrapper.eq("user_id",userId);
        freezeMapper.delete(queryWrapper);
    }
}
